<style>
	.datatable {
		text-align: left;
		font-size: 12px;
		font-family: verdana;
		background: #c0c0c0; margin:2px;
	}

	.datatable thead tr,

	.datatable tfoot tr {
		background: #c0c0c0;
	}

	.datatable tbody tr {
		background: #f0f0f0;
                height: 100px;
	}

	.datatable td, th {
		border: 1px solid white; height:28px;
	}
	.datatable td {background-color:white;}
	
	.datatable .hover td {background-color:#99CCFF;}
	
	.datatable .select td {background-color:#EEEE99;}

	#ui-datepicker-div{ font-size:12px;}
</style>
<div style="height: 20px;margin-left: 50px;margin-top: 10px;color: red;"><?php echo $this->message;?></div>
<div style="padding:2px; margin:2px;" class="dataTable">
    <form action=""  method="get" style="margin:0px" id="form1">
        <div style=" border:1px solid #DDDDDD; padding:2px; margin:2px;line-height: 36px;" id='sel'> 
            <label for="name">用户名：</label><input type="text" id="username" name="username" value="<?php echo $this->nikename;?>"/>
            <label for="storeno">仓库号：</label><input type="text" id="storeno" name="storeno" value="<?php echo $this->storeno;?>" />
                <select id="dateselect" name="dateselect">
                  <option value="create" <?php if($this->dateselect=='create'){echo "selected";} ?>>提交时间</option>
                  <option value="send" <?php if($this->dateselect=='send'){echo "selected";} ?>>发货时间</option>
                </select>
            <label for="starttime">：</label><input type="text" id="starttime" name="starttime" value="<?php echo $this->starttime;?>" />
            <label for="endtime">-- </label><input type="text" id="endtime" name="endtime" value="<?php echo $this->endtime;?>"  />
            <label for="status">状态：</label>
            <select id="status" name="status">
                  <?php foreach ($this->arrsta as $key => $val){?>
                    <option value="<?php echo $key;?>" <?php if($this->status==$key){echo "selected";}?>><?php echo $val;?></option>
                  <?php }?>
                    <option value="" <?php if($this->status==""){echo "selected";}?>>所有</option>
            </select>
            <input type="submit" id="queryButton" name="queryButton" value="查询"/>
        </div>
    </form>
<table cellspacing="1" width="100%" class="datatable" id="waybill-table">
	<thead>
		<tr >
                        <th class="w0" width="15px"></th>
			<th class="w1">运单号<br>状态</th>
			<th class="w0">提交时间</th>
			<th class="w1">用户信息</th>
                        <th class="w0">国际<br>城市</th>
			<th class="w1">收货人信息</th>
			<th class="w0">费用</th>
			<th class="w1">打包信息</th>
                        <th class="w0">发货费用</th>
                        <th class="w1">发货渠道</th>
		</tr>
	</thead>
    <tfoot>
      <tr><td colspan="14"><button class="button" id="hear-button">运单受理</button><button class="button" id="accep-button">查看发货清单</button>
          <button class="button" id="shipments-button">确认发货</button>
          <button class="button" id="singleno-button">生成转单号</button><button class="button" id="cancel-button">退货</button></td></tr>
    </tfoot>
	<tbody>
                <?php
                    if( $this->billlist != ''){
                    foreach ($this->billlist as $Item) {?>
                    <?php 
//                        $useritem = new Application_Model_User();
//                        $userdateil = $useritem->getUserDetail($Item->userId);
//                        $usership = new Application_Model_shipType();
//                        $usershiptype = $usership->getUserShipType($Item->shipType);
                        $city = new Application_Model_city();
                        $citydetail = $city->getUserCity($Item->state);
                        $agent = new Application_Model_AgentCompany();
                        $agentdetail = $agent->getAgentOne($Item->agentId);
                    ?>
                    <tr height='64px'>
                        <td class="w0"><?php if($Item->statustype){?><input type="checkbox" value="<?php echo $Item->id;?>" class="checkbox-del" name='checkbox'  /><?php }?></td>
                        <td class="w1"><?php echo $Item->billNo;?><br><?php echo $Item->statusname;?></td>
                        <td class="w0"><?php echo $Item->dateCreated;?><br>发货时间：<?php echo $Item->dateSend;?></td>
                        <td class="w1"><?php echo '用户序号：'.$Item->user->id;?><br><?php echo '用户名：'.$Item->user->nikename;?><br><?php echo '仓库号：'.$Item->user->storeno;?></td>
                        <td class="w0"><?php echo $citydetail->name;?></td>
                        <td class="w1">收货人：<?php echo $Item->consignee;?><br>
                            电话：<?php echo $Item->conTel;?><br>
                            邮编：<?php echo $Item->conPostCode;?><br>
                            地址：<?php echo $Item->conAdd;?><br></td>
                        <td class="w0">
                            商品总量：<?php echo $Item->productWeight;?>g<br>
                            包裹总量：<?php echo $Item->bagWeight;?>g<br>
                            总重量&nbsp;&nbsp;&nbsp;：<?php echo ($Item->productWeight+$Item->bagWeight);?>g<br>
                            体积总量：<?php echo $Item->volumeWeight;?>g<br>
                            结算总量：<?php if($Item->volumeWeight>($Item->productWeight+$Item->bagWeight)){echo $Item->volumeWeight;}else{echo $Item->productWeight+$Item->bagWeight;}?>g <br>
                        </td>
                        <td class="w1">去吊牌&nbsp;&nbsp;&nbsp;：<?php if($Item->isNoLogo==1){echo "是";}else{echo "否";}?><br>
                            去包装&nbsp;&nbsp;&nbsp;：<?php if($Item->isNoSkin==1){echo "是";}else{echo "否";}?><br>
                            压缩&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;：<?php if($Item->isCompress==1){echo "是";}else{echo "否";}?><br>
                            支付费用：￥<?php echo $Item->shipMoney;?><br>
                            报关费&nbsp;&nbsp;&nbsp;：￥<?php echo $Item->reportFee;?><br>
                        </td>
                        <td class="w0">实际重量：<?php echo $Item->lastWeight;?>g<br>
                            实际体积：<?php echo $Item->volumeWeight;?>g<br>
                            收款：￥<?php echo $Item->lastMoney;?><br>
                            成本价：￥<?php echo $Item->costMoney;?><br>
                            利润：￥<?php echo $Item->lastMoney-$Item->costMoney;?><br>
                        </td>
                        <td class="w1">公司：<?php echo $agentdetail->name;?><br>
                            渠道：<?php echo $Item->expressCostId;?><br>
                            物流号：<?php echo $Item->logistics;?><br>
                            货单号：<?php echo $Item->agentNo;?><br>
                        </td>
                    </tr>
                <?php } }?>
	</tbody>
</table>
<script>
    $('#cancel-button').click(function(){
        var id = getbillid();
        if(id == ''){
            alert("请选择运单");
            return false;
        }else{
            if(confirm("您确定该运单退货？","提示信息")){
                location.href='/admini/managewaybill/cancel/id/'+id;
            }
        }
    });
    $('#shipments-button').click(function(){
        var id = getbillid();
        if(id == ''){
            alert("请选择运单");
            return false;
        }else{
            location.href='/admini/managewaybill/shipments/id/'+id;
        }
    });
    $('#singleno-button').click(function(){
        var id = getbillid();
        if(id == ''){
            alert("请选择运单");
            return false;
        }else{
            location.href='/admini/managewaybill/singleno/id/'+id;
        }
    });
    $('#accep-button').click(function(){      
        
        var id = getbillid();
        if(id == ''){
            alert("请选择运单");
            return false;
        }else{
            location.href='/admini/managewaybill/billaccep/id/'+id;
        }
    });
    $('#hear-button').click(function(){
         var idlist = '';
         $('input[name="checkbox"]:checked').each(function(){    
		idlist+= $(this).val()+',';
	});
        if(idlist == ''){
            alert("请选择运单");
            return false;
        }else{
            location.href='/admini/managewaybill/billhear/idlist/'+idlist;
        }
    });
    function getbillid()
    {
         var id = '';
         $('input[name="checkbox"]:checked').each(function(){    
		id = $(this).val();
                return false;
	});
        return id;
    }
</script>
 <?
                
    echo $this->partial('paging.phtml',array("pages"=>$this->billall));
                
?>
</div>
<script language="javascript">
    $('.Page a').unbind().click(function(){
        var href = $(this).attr('href');
        var formto = $('#form1').attr("action");
        if(formto.length>=0){
            $('#form1').attr("action", formto+href)
            $('#form1').submit();
            return false; 
        }else{
            return true;
        }
    });
</script>
